<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p>{{username}}</p>
        <p>{{password}}</p>
        <form action="" @submit.prevent="submitHandler">
            <label for="">
                用户名:<input type="text" v-model="userInfo.username" class="username">
            </label>
            <label for="">
                密码:<input type="text" v-model="userInfo.password" class="password">
            </label>
            <button>登录</button>
        
        </form>
        <input type="reset" @click="resetHandler" value="重置">
    </div>
    <script src="./vue.global.js"></script>
    <script>

        /* 
            原生js 
            const form = document.querySelector('form');
            const username = document.querySelector('.username');
            const password = document.querySelector('.password');
            form.onsubmit = function(e){
                e.preventDefault;
                const info = {
                    username:username.value,
                    password:password.value
                }
            }

            axios.post('',info)
        
        */
        const {createApp} = Vue;

        createApp({
            data(){
                return {
                    // username:'',
                    // password:''
                    userInfo:{}
                }
            },
            methods:{
                submitHandler(){
                    console.log('提交表单',this.username);
                    console.log('提交表单',this.password);

                },
                resetHandler(){
                    this.userInfo = {}
                }
            }
        }).mount('#app');
    </script>
</body>
</html>